package org.john.javalib;

import java.util.HashMap;

/**
 * Created by adsame on 18-11-3.
 */
public class MapTest {
    static class MT {
        int a = 0;
        int b = 0;
        public MT() {

        }
        public MT(int i) {
            this.b = i;
        }
        public boolean equals(Object obj) {
            MT m = (MT) obj;
            return m.a == a;
        }
    }
    public static void main(String args[]) {
        HashMap<Integer, MT> map = new HashMap<Integer, MT>();
        HashMap<Integer, MT> map2 = new HashMap<Integer, MT>();
        HashMap<Integer, MT> map3 = new HashMap<Integer, MT>();
        MT s = new MT();
        map.put(1, new MT());
        map.put(1, s);
        map2.put(1, s);
        map3.put(1, new MT(2));
        System.out.println(map.size());
        System.out.println("hashcode map1:" + map.hashCode() + ", map2:" + map2.hashCode() + ", map3:" + map3.hashCode());
        System.out.println("equal test1,2:" + map.equals(map2) + ", test1,3:" + map.equals(map3));
    }
}
